<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>酒店规格</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <form class="layui-form serch" action="{:url('admin/hotel/hotelspec')}" method="post">
            <div class="layui-input-inline">
                <input type="text" name="keywords" autocomplete="off" value="{notempty name='$hotelSpecParams.keywords'}{$hotelParams.keywords}{/notempty}" lay-verify="title" placeholder="请输入id/名称" class="layui-input layui-btn-sm">
            </div>
            <div class="layui-input-inline">
                <select class="layui-select" name="hotel_id" id="hotel_id">
                    <option value="">请选择类型</option>
                    <option value="0" {if isset($hotelSpecParams.hotel_id) && $hotelSpecParams.hotel_id=='0'}selected{/if}>通用</option>
                    {notempty name="$hotelList"}{volist name="hotelList" id="vo"}
                    <option value="{$vo.hotel_id}" {if isset($hotelSpecParams.hotel_id) && $hotelSpecParams.hotel_id==$vo.hotel_id}selected{/if}>{$vo.name}</option>
                    {/volist}{/notempty}
                </select>
            </div>
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-sm">查询</button>
                <a class="layui-btn layui-btn-normal layui-btn-sm addNewSpec">新增规格</a>
            </div>
        </form>

    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="10%">
            <col width="10%">
            <col width="10%">
            <col width="20%">
            <col width="40%">
            <col width="10%">
        </colgroup>
        <thead>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>类型</th>
            <th>属性</th>
            <th>属性值</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {if !empty($list)}
        {volist name="list" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.spec_name}</td>
            <td>{notempty name='$vo.hotel_id'}酒店ID-{$vo.hotel_id}{/notempty}
                {empty name='$vo.hotel_id'}通用{/empty}</td>
            <td>{if !empty($vo.attr_json) && $attrNames = array_column($vo.attr_json,'name')}
                {notempty name='$attrNames'}
                {$attrNames|implode=",",###}
                {/notempty}
                {/if}</td>
            <td>
                {notempty name='$vo.attr_json'}
                {volist name='vo.attr_json' id='value'}
                {notempty name='value.sub'}
                {$value.sub|array_column=###,'name'|implode=',',###}<br>
                {/notempty}
                {/volist}
                {/notempty}
            </td>
            <td>

            </td>
        </tr>
        {/volist}
        {/if}
        </tbody>
    </table>
    <div>{$list->render()}</div>
</div>
</body>
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
    layui.use(['layer','form'], function() {
        var layer = layui.layer;
        var form = layui.form;

        //新增酒店
        $(".addNewSpec").click(function(){
            var url = '{:url("admin/hotel/addNewHotelSpec")}';
            layer.open({
                title:'新增规格',
                type:2,
                area:['80%','80%'],
                content:url,
                end:function () {
                    window.location.reload();
                }
            })
        })

        $(".jumpUrl").click(function () {
            var url = $(this).attr('href');
            layer.open({
                title:'信息',
                type:2,
                area:['80%','80%'],
                content:url,
                end:function () {

                }
            })
            return false;
        })

        $(".delSpec").click(function () {
            var url = $(this).attr('href');
            layer.confirm('确认删除该酒店信息?',function(){
                //开启加载logo
                var add_load_index = layer.load(2,{shade: [0.5, '#393D49']});
                $.post(url,{},function (res) {
                    layer.close(add_load_index);
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        setTimeout(function(){
                            window.location.reload();
                        },1500)
                    }
                },'json')
            })
            return false;
        })
    });

</script>
</html>
